<?php

namespace App\Model\Home;

use Illuminate\Database\Eloquent\Model;
use App\Model\Admin\Category;

class Index extends Model
{
    //
	public function getTree($data,$cate_id){
		$catesID = Category::all();
		$subids = $this->getSubId($catesID,$cate_id);
		$result = array();
		foreach ($data as $key => $value) {
			if(in_array($value->cate_id, $subids)){
				$result[] = $data[$key];
			}
		}
		return $result;
	}
	public function getSubId($data,$cate_id){
		$saveid[] = $cate_id;
		foreach ($data as $key => $value) {
			if($value->cate_pid == $cate_id){
				$saveid[] = $value->cate_id;
			}
		}
		return $saveid;
	}
}
